import React,{useState} from 'react'
//引入antd
import {Modal, Radio,Calendar} from "antd";
import moment from "moment";
import http from "../../../../../services/service";


function EditModal(props) {
    let [status,setStatus] = useState(props.status);

    //点击确定
    let handleOk = () => {
        props.onOk(status);
    };
    //点击关闭
    let handleCancel = () => {
        props.onCancel();
    };
    //单选框的选中
    let onChange = e => {
        setStatus(e.target.value)
    };

    return (
        <div>
            {/*状态管理模态框*/}
            <Modal title="修改状态" {...props} onOk={handleOk} onCancel={handleCancel}>
                <div>
                    <span>目标状态</span>
                    <Radio.Group onChange={onChange} value={status}>
                        <Radio value="0">待体检{status}</Radio>
                        <Radio value="1">待支付</Radio>
                        <Radio value="2">已体检</Radio>
                        <Radio value="3">已取消</Radio>
                    </Radio.Group>
                </div>
            </Modal>
        </div>


    )
}

function TimeModal(props) {
    let {cTime,value} = props;
    const [time,setTime] = useState(cTime);
    //点击确定
    let handleOk = () => {
        props.onOk("time");
    };
    //点击关闭
    let handleCancel = () => {
        props.onCancel("time");
    };
    //选择日历时间的回调
    let timeOnChange = (date) => {
        let time = moment(date._d).format("YYYY-MM-DD");
        setTime(date._d)
        props.setTime(time)
    };
    return (
        <div>
            {/*状态管理模态框*/}
            <Modal title="修改状态" {...props} onOk={handleOk} onCancel={handleCancel}>
                <div>
                    <Calendar value={moment(value)} onSelect={timeOnChange} fullscreen={false}/>
                </div>
            </Modal>
        </div>


    )
}

export {
    EditModal, TimeModal
}
